# python中没有真正的私有化，但是有一些和命名有关的约定，来让编程人员处理一些需要私有化的情况
class Person:
    def __init__(self, name='', gender=''):
        self.name = name
        self.gender = gender

    # _ 私有属性或方法，约定不在类外调用这个方法但也能调用
    def _say(self, some):
        return f"{self.name}: {some}"

    # __ 避免子类覆盖其内容
    def __say(self, some):
        return f"{self.name}: {some}"

    # __ 避免子类覆盖其内容
    def __method(self):
        print('Person')

    def method(self):
        self.__method()

    def func(self, some):
        return self.__say(some)

class Singer(Person):
    __feature = "sing song"
    def __method(self):
        print('Singer')

    def doit(self):
        return f"I am a {self.__class__.__name__}"

p = Person("cqz", 1)
print(dir(Person))
print(p._say('222'))

s = Singer()
s.method()

# print(dir(p))
# print(p._Person__say("hello world!"))
# print(p.func("hello world!"))
# print(p.__class__.__name__)
# print(Person.__name__)
# p.__delattr__("name")
# p.__setattr__('name', 'chenqinzhao')
# p.name = 'chenqinzhao'
# print(p.name)
# print(p.func("hello world!"))
# print(dir(p))
# s = Singer()
# print(s._Singer__feature)
# print(s.__feature)
# print(s.feature)
# print(s.doit())